package com.hbnu.service;

import com.hbnu.dao.UserDao;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional //事务注解
public class UserService {

    //UserService引入Userdao
//    @Resource(name = "userDao")
    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void addUser(){
//        System.out.println("添加：沉醉不知归处，误入藕花深处");
        userDao.addUser();
    }

    public void account(String sendUser, String receiveUser, Double money){
        userDao.lessMoney(sendUser, money);
        int i = 100 / 0;
        userDao.moreMoney(receiveUser, money);
    }
}
